home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / Mesa-2.2 / src / interp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-03-13  |  3.4 KB  |  140 lines

  1. /* $Id: interp.h,v 1.2 1996/09/25 02:01:28 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  2.0
  6.  * Copyright (C) 1995-1996  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: interp.h,v $
  26.  * Revision 1.2  1996/09/25 02:01:28  brianp
  27.  * removed gl_interp_texcoords() and gl_interp_texcoords2()
  28.  *
  29.  * Revision 1.1  1996/09/13 01:38:16  brianp
  30.  * Initial revision
  31.  *
  32.  */
  33.  
  34.  
  35. #ifndef INTERP_H
  36. #define INTERP_H
  37.  
  38.  
  39. #include "types.h"
  40.  
  41.  
  42. /*
  43.  * Various integer interpolation functions and macros
  44.  */
  45.  
  46.  
  47.  
  48. extern void gl_interpolate_z( GLint n, GLint z0, GLint z1, GLdepth zspan[] );
  49.  
  50.  
  51. extern void gl_interpolate_i( GLint n, GLint y0, GLint y1, GLint yspan[] );
  52.  
  53.  
  54. extern void gl_interpolate_rgba( GLint n,
  55.                                  GLfixed r0, GLfixed r1, GLubyte rspan[],
  56.                                  GLfixed g0, GLfixed g1, GLubyte gspan[],
  57.                                  GLfixed b0, GLfixed b1, GLubyte bspan[],
  58.                                  GLfixed a0, GLfixed a1, GLubyte aspan[] );
  59.  
  60.  
  61.  
  62. #ifdef DEBUG
  63.  
  64. #define GL_INTERPOLATE_Z(N,Z0,Z1,ZSPAN)   gl_interpolate_z(N,Z0,Z1,ZSPAN)
  65.  
  66. #else
  67.  
  68. #define GL_INTERPOLATE_Z(N,Z0,Z1,ZSPAN)    \
  69. {                    \
  70.    GLint zz0, zz1, dzz, ii;        \
  71.    switch (N) {                \
  72.       case 1:                \
  73.      ZSPAN[0] = Z0;            \
  74.      break;                \
  75.       case 2:                \
  76.      ZSPAN[0] = Z0;            \
  77.      ZSPAN[1] = Z1;            \
  78.      break;                \
  79.       case 3:                \
  80.      ZSPAN[0] = Z0;            \
  81.      ZSPAN[1] = ((Z0)+(Z1)) >> 1;    \
  82.      ZSPAN[2] = Z1;            \
  83.      break;                \
  84.       default:                \
  85.          zz0 = (Z0) << 7;        \
  86.      zz1 = (Z1) << 7;        \
  87.      dzz = (zz1-zz0) / ((N)-1);    \
  88.      for (ii=0;ii<(N);ii++) {    \
  89.         ZSPAN[ii] = zz0 >> 7;    \
  90.         zz0 += dzz;            \
  91.      }                \
  92.    }                    \
  93. }
  94.  
  95.  
  96.  
  97. #endif  /*DEBUG*/
  98.  
  99.  
  100.  
  101.  
  102. /*
  103.  * Macro version of gl_interpolate_rgba()
  104.  */
  105. #define GL_INTERPOLATE_RGBA( N, R0,R1,R, G0,G1,G, B0,B1,B, A0,A1,A )    \
  106.     if ((N)<2) {                    \
  107.        R[0] = FixedToInt(R0);            \
  108.        G[0] = FixedToInt(G0);            \
  109.        B[0] = FixedToInt(B0);            \
  110.        A[0] = FixedToInt(A0);            \
  111.     }                        \
  112.     else if ((N)==2) {                \
  113.            R[0] = FixedToInt(R0);            \
  114.            R[1] = FixedToInt(R1);            \
  115.        G[0] = FixedToInt(G0);            \
  116.        G[1] = FixedToInt(G1);            \
  117.        B[0] = FixedToInt(B0);            \
  118.        B[1] = FixedToInt(B1);            \
  119.        A[0] = FixedToInt(A0);            \
  120.        A[1] = FixedToInt(A1);            \
  121.     }                        \
  122.     else {                        \
  123.        GLfixed r0, dr, g0, dg, b0, db, a0, da;    \
  124.        GLint ii, nn = (GLint) (N) - 1;        \
  125.        r0 = R0;   dr = (R1-r0) / nn;        \
  126.        g0 = G0;   dg = (G1-g0) / nn;        \
  127.        b0 = B0;   db = (B1-b0) / nn;        \
  128.        a0 = A0;   da = (A1-a0) / nn;        \
  129.        for (ii=0;ii<(N);ii++) {            \
  130.           R[ii] = FixedToInt(r0);    r0+=dr;        \
  131.           G[ii] = FixedToInt(g0);    g0+=dg;        \
  132.           B[ii] = FixedToInt(b0);    b0+=db;        \
  133.           A[ii] = FixedToInt(a0);    a0+=da;        \
  134.        }                        \
  135.     }
  136.  
  137.  
  138. #endif  /* INTERP_H */
  139.  
  140.